const mongoose = require('mongoose');
const db = require('./index.js');
const userSchema = new mongoose.Schema({
  name: String,
  age: Number,
  updata: {
    type: Date,
    default: Date.now()
  }
});

const user = db.model('user', userSchema);

const findAll = function() {
  return new Promise((s, f) => {
    user.find({},{name:'name', age:'age', add: 'add'},(err, data) => {
      if (err) {
        f(false);
        log.error('查询全部用户失败');
        log.error(err);
        return false;
      }
      s(data);
      log.debug('查询全部用户成功');
      console.log(data);
      log.debug('**********************');
    })
  })
}

module.exports = {
  findAll: findAll
}